package cn.matrix42.potoo.jdbc.dialect.derby;

import cn.matrix42.potoo.jdbc.dialect.AbstractDialect;

import java.util.Optional;

public class DerbyDialect extends AbstractDialect {

    private static final String DRIVER = "com.mysql.jdbc.Driver";
    private static final String URL_PATTERN = "jdbc:derby:%s";

    @Override
    public String dialectName() {
        return "Derby";
    }

    @Override
    public String getLimitClause(long limit) {
        return String.format("FETCH FIRST %d ROWS ONLY", limit);
    }

    @Override
    public String quoteIdentifier(String identifier) {
        return identifier;
    }

    @Override
    public Optional<String> getUpsertStatement(String tableName, String[] fieldNames, String[] uniqueKeyFields) {
        return Optional.empty();
    }

    @Override
    public String getDriver() {
        return DRIVER;
    }

    @Override
    public String getUrlPattern() {
        return URL_PATTERN;
    }
}
